<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>软件部署</title>
    <link rel="stylesheet" href="${ctx}/assets/css/amazeui.min.css" />
    <link rel="stylesheet" href="${ctx}/assets/css/app.css">
    <link rel="stylesheet" href="${ctx}/assets/css/layer.css">
    <link rel="stylesheet" href="${ctx}/assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="${ctx}/assets/css/taskAlgorithmSettingByBatchTasks.css">
    <link rel="stylesheet" type="text/css" href="${ctx}/assets/css/xcConfirm.css"/>
</head>
<body>
<div class="form-main">
    <input type="hidden" id="task_number">
    <div class="form-header">
        <h3 id="y-title">软件部署</h3>
    </div>
    <hr>

    <div class="content" id="param_form">
        <input id="hostIP" type="hidden" />
    </div>
    <hr>
    <!-- <div class="action mr20" style="float: right;" id="closeIframe">
        <ul class="actions-btn"><li class="green">取消</li></ul>
    </div>
    <div class="action mr20" style="float: right;" id="saveSetting">
        <ul class="actions-btn"><li class="green">提交</li></ul>
    </div> -->
</div>
<script src="${ctx}/assets/js/jQuery/jquery-1.9.1.js"></script>
<script src="${ctx}/assets/js/jQuery/jquery.min.js"></script>
<script src="${ctx}/assets/js/common/config.js"></script>
<script src="${ctx}/assets/js/common/common.fun.js"></script>
<script src="${ctx}/assets/js/common/bootstrap.js"></script>
<script src="${ctx}/assets/js/common/xcConfirm.js"></script>
<script src="${ctx}/assets/js/layer/layer.js"></script>
<script>
$(function () {
	var hostIP = GetQueryString("hostIP");
	$.ajax({
        type:"GET",
        url:constUrl+"ws/remote/host/readScript",
        dataType:"json",
        data: {
        	scripType:"deploy"
        },
        success:function(data){
        	console.log(data);
        	var files = data.data
        	var inputs = "";
        	for(var i=0;i<files.length;i++){
        		inputs = inputs+"<a onclick=uploadDeployFile('"+files[i]+"','"+hostIP+"')>"+files[i]+"</a></br></br>";
        	}
        	$("#param_form").html(inputs);
        }
    });
});

function uploadDeployFile(fileName,IPS){
	$.ajax({
        type:"POST",
        url:constUrl+"ws/remote/app/download",
        dataType:"json",
        data: {
        	IPS:IPS,
        	filePath:fileName,
        	execType:"deploy"
        },
        success:function(data){
        	
        	formClose();
        	
        },error:function(data){
        	layer.msg('上传失败，请联系管理员', {
                time: 2000 //1s后自动关闭
        			});
        }
    });
}

function formClose(){
	layer.msg('上传成功', {
        time: 2000 //1s后自动关闭
			});
	var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
    //layer.msg(index);
    parent.layer.close(index); //再执行关闭 
}

</script>
</body>
</html>